Repository navigation
Conversation
|
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Hash-floor selection and normalization errors can reject valid signatures, while failed test setup can trigger a crypto free callback on an uninitialized RSA key.
3 open issues
What changed in this PR
This PR hardens wolfCrypt’s signature wrappers for non-blocking keys and applies minimum hash-strength checks consistently across entry points.
Changes:
- Fixes non-blocking RSA buffer ownership and ECC retry handling.
- Tightens signature validation and clears signatures when self-checks fail.
- Adds regression tests and updates API documentation.
| File | Description |
|---|---|
| wolfssl/wolfcrypt/signature.h | Defines default hash-floor selection and policy. |
| wolfcrypt/src/signature.c | Updates non-blocking handling, validation, and hash enforcement. |
| tests/api/test_signature.h | Registers new signature tests. |
| tests/api/test_signature.c | Adds hash-floor and non-blocking regression coverage. |
| doc/dox_comments/header_files/signature.h | Documents argument and hash-strength restrictions. |
Review effort: Balanced
… the signature wrapper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Description
Fixes
wolfcrypt/src/signature.cfor non-blocking keys and closes gaps in its minimum hash strength check.wc_SignatureVerifyHash()gave its temporary buffer towc_RsaSSL_VerifyInline(). A non-blockingRsaKeykeeps that buffer acrossFP_WOULDBLOCKreturns, after the wrapper has freed it. Non-blocking keys now usewc_RsaSSL_Verify(), so the key owns its working buffer. (F-19063)MP_WOULDBLOCKto the caller instead ofSIG_VERIFY_E, which left the operation pending in the key. (F-19269)wc_SignatureGenerate*()finishes its post-sign self-check within the call for non-blocking keys. If the check fails, it wipes the signature and sets*sig_lento 0. (F-18525)wc_SignatureGetSize()result is now returned instead of skipping the length check (F-7078).sig_lenis compared unsigned (F-16919). A NULL key returnsBAD_FUNC_ARGfor every signature type (F-12152).wc_SignatureVerifyHash()andwc_SignatureGenerateHash*()(F-6905) and rates MD5+SHA-1 as SHA-1 (F-16573). Strength is rated by nominal digest size, so the floor holds even when the floor hash itself isn't compiled in (F-9939).Behavior change: callers of the
*HashAPIs that pass MD5, SHA-1 or MD5+SHA-1 now getBAD_FUNC_ARGunless they define a lowerWC_SIG_MIN_HASH_TYPE. That matcheswc_SignatureVerify()andwc_SignatureGenerate()since v5.9.4.wc_SignatureGetSize()with a NULL ECC key now returnsBAD_FUNC_ARGinstead of 0.Resolves F-19063, F-19269, F-18525, F-7078, F-16919, F-12152, F-6905, F-16573, F-9939.
Testing
New tests in
tests/api/test_signature.ccover non-blocking RSA and ECC through the wrapper, and the hash floor. Without the fix, the RSA test reports a heap-use-after-free under ASan.--enable-all(unit.test --api),--enable-wolfclu, and-Werrorbuilds without RSA, without MD5/SHA-1, SHA-512 only, and SHA3 only.